package com.baizhi.controller;

import com.baizhi.Employee;
import com.baizhi.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class EmployeeController {
    @Autowired
    private EmployeeService es;
    @PostMapping("employees")
    public void insertEmployee(@RequestBody Employee employee){
        es.insertEmployee(employee);
    }
    @GetMapping("/employees")
    public Map<String,Object> show(int page, int limit){
        final List<Employee> employees = es.selectALLs();
        System.out.println(employees);
        return new HashMap<String, Object>(){
            {put("msg","");
                put("code",0);
                put("data",employees);
            }
        };
    }
}
